package com.ziyia.roomtest;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;


import java.util.List;

@Dao
public interface UserDao {
    @Insert
    Long insertUser(User user);

    @Update
    void updateUser(User user);

    @Query("select * from User")
    List<User> loadAllUsers();

    //
    @Query("select * from User where age > :age")
    List<User> loadUser(int age);

    // 会根据User中的主键去删除
    @Delete
    void deleteUser(User user);

    // SQL语句的形式删除
    @Query("delete from User where name = :name")
    int deleteUserByName(String name);
}
